# Build and serve using Node
FROM node:20

WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install

COPY . .

# 设置环境变量
ENV PORT=8080
ENV HOST=0.0.0.0

# 构建应用
RUN yarn build

# 安装 serve 包来提供静态文件服务
RUN yarn global add serve

EXPOSE 8080

# 使用 serve 启动应用
CMD ["serve", "-s", "dist", "-l", "8080"]